package com.qiaoanju.back.dao.system;

import com.qiaoanju.back.domain.system.GroupModel;
import com.qiaoanju.dao.SqlMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Created by eversec
 * on 2017/9/23.
 */
public interface IGroupDao extends SqlMapper {


    @Insert("insert into t_group(group_name, enable, create_time, update_time, create_id, pid, group_level, update_id) values(#{group_name}, #{enable}, #{create_time}," +
            "#{update_time}, #{create_id}, #{pid}, #{group_level}, #{update_id})")
    int insert(GroupModel Group);


    @Select("select * from t_group where id = #{id}")
    GroupModel getGroupById(int id);

    @Select("select * from t_group where pid = #{root}")
    List<GroupModel> getChildsByRoot(int root);

    @Update("update t_group set group_name = #{menu_name}, pid = #{pid},enable = #{enable}, group_level = #{group_level}, " +
            "update_time = #{update_time}, update_id = #{update_id} where id = #{id}")
    boolean edit(GroupModel group);
}
